<template xmlns="http://www.w3.org/1999/html">
  <sea-dialog ref="dialog">
  </sea-dialog>
</template>

<script>


export default {
    components: {},
    data() {
        return {
            // 成功回调，通常是刷新数据表格
            onSucceed: {type: Function, default: undefined}
            // end--
        }
    },
    methods: {
        /**
         * 操作成功回调
         */
        onSucceed: function () {
        },
        /**
         * 操作栏事件分发
         * @param evt 事件
         * @param row 行级对象
         * @param old 可供回滚的参数
         */
        onAction: function (evt, row, old) {
            this.operation = evt;
            if (evt === 'new') {
                let dialog = {title: '新建', fullscreen: true};
                this.$refs.dialog.open(dialog).then(() => this.row_data = row);
            } else if (evt === 'edit') {
                let dialog = {title: '编辑', fullscreen: true};
                this.$refs.dialog.open(dialog).then(() => this.row_data = row);
            } else if (evt === 'del') {
                this.$layers.delete({
                    url: '/'
                    , method: 'DELETE'
                    , params: {id: row.id}
                }).then((ret) => {
                    if (ret.code === 0) {
                        this.$layers.succeed();
                    }
                });
            }
        }
    }
}
</script>
